<%@page import="com.healtyprj.Constants"%>
<%@page import="com.healtyprj.User"%>
<%@page import="com.amazonaws.util.json.JSONObject"%>
<%@page import="org.springframework.util.StringUtils"%>
<%@page import="com.amazonaws.services.dynamodb.datamodeling.DynamoDBMapper"%>
<%@page import="com.amazonaws.services.dynamodb.model.PutItemResult"%>
<%@page import="com.amazonaws.services.dynamodb.model.PutItemRequest"%>
<%@page import="java.util.Map"%>
<%@page import="java.util.HashMap"%>
<%@page import="com.amazonaws.services.dynamodb.model.AttributeValue"%>
<%@page import="com.amazonaws.AmazonServiceException"%>
<%@page import="com.amazonaws.services.dynamodb.model.TableStatus"%>
<%@page import="com.amazonaws.services.dynamodb.model.DescribeTableRequest"%>
<%@page import="com.amazonaws.services.dynamodb.model.TableDescription"%>
<%@page import="com.amazonaws.services.dynamodb.model.ProvisionedThroughput"%>
<%@page import="com.amazonaws.services.dynamodb.model.KeySchemaElement"%>
<%@page import="com.amazonaws.services.dynamodb.model.KeySchema"%>
<%@page import="com.amazonaws.services.dynamodb.model.CreateTableRequest"%>
<%@page import="com.amazonaws.auth.ClasspathPropertiesFileCredentialsProvider"%>
<%@page import="com.amazonaws.services.dynamodb.AmazonDynamoDBClient"%>
<%@page import="com.amazonaws.services.dynamodb.AmazonDynamoDB"%>
<%@ page language="java" contentType="text/x-json; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("UTF-8");
String name = new String(request.getParameter("name").getBytes("8859_1"), "UTF-8");
String pass = new String(request.getParameter("pass").getBytes("8859_1"), "UTF-8");

AmazonDynamoDB dynamoDB = new AmazonDynamoDBClient(new ClasspathPropertiesFileCredentialsProvider());
dynamoDB.setEndpoint(Constants.REGION);

DynamoDBMapper dynamoDBMapper = new DynamoDBMapper(dynamoDB);
User user = dynamoDBMapper.load(User.class, name);

JSONObject json = new JSONObject();
boolean isLogin = user.getName().equals(name)
			&& user.getPassword().equals(pass);
json.put("login", isLogin);
out.print(json.toString());
%>